package com.jy.service.impl;

import com.jy.common.ResultInfo;
import com.jy.exception.CustomException;
import com.jy.service.IGetPlateNumberService;
import com.jy.utils.FileUtil;
import com.jy.utils.LicensePlate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author Xiexingxie
 * @date 2022/11/9 下午 03:20
 */

@Service
public class GerPlateNumberImpl implements IGetPlateNumberService {

    @Override
    public String licensePlate(MultipartFile multipartFile) {
        try {
            File file = FileUtil.uploadFile(multipartFile);
            String result = LicensePlate.licensePlate(file.getAbsolutePath());
            if (result != null) {
                return result;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        throw new CustomException(20001, ResultInfo.PLATENUMBER_NOT_RESULT_LIST);

    }
}
